package com.ruoyi.drawing.test;

import lombok.extern.slf4j.Slf4j;

/**
 * 罗马数字转整数
 *
 * @author ZhangYu
 * @date 2024/10/19 17:14
 */
@Slf4j
public class RomanNumeralsToIntegers {

    /**
     * I             1
     * V             5
     * X             10
     * L             50
     * C             100
     * D             500
     * M             1000
     *
     * @param args
     */
    public static void main(String[] args) {
        String string = "IV";
        char[] charArray = string.toCharArray();
        int result = 0;
        for (char item : charArray) {
            switch (item) {
                case 'I':
                    result += 1;
                    break;
                case 'V':
                    result += 5;
                    break;
                case 'X':
                    result += 10;
                    break;
                case 'L':
                    result += 50;
                    break;
                case 'C':
                    result += 100;
                    break;
                case 'D':
                    result += 500;
                    break;
                case 'M':
                    result += 1000;
                    break;
                default:
                    break;
            }
        }
        log.info("------------------------------------------------------------------------------------------{}", result);
    }

}
